package com.coda.app.controller;

import com.coda.app.service.LeaseAgreementService;
import com.coda.appVo.agreement.AgreementDetailVo;
import com.coda.appVo.agreement.AgreementItemVo;
import com.coda.entity.LeaseAgreement;
import com.coda.entity.LeaseTerm;
import com.coda.entity.PaymentType;
import com.coda.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/agreement")
@Api(tags = "租约信息")
public class LeaseAgreementController {

    @Autowired
    private LeaseAgreementService leaseAgreementService;
    /**
     * 获取个人租约基本信息
     */
    @GetMapping("listItem")
    @ApiOperation("获取个人租约基本信息")
    public Result<List<AgreementItemVo>> getList(){
        List<AgreementItemVo> agreementItemVos = leaseAgreementService.getList();
        return Result.ok(agreementItemVos);
    }

    /**
     * 根据id获取租约详细信息
     */
    @GetMapping("/getDetailById")
    @ApiOperation("根据id获取租约详细信息")
    public Result<AgreementDetailVo> getDetail(@RequestParam Long id){
        AgreementDetailVo agreementDetailVo = leaseAgreementService.getDetail(id);
        return Result.ok(agreementDetailVo);
    }

    /**
     * 保存或更新租约
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperation("保存或更新租约")
    public Result saveOrUpdate(@RequestBody LeaseAgreement leaseAgreement){
        leaseAgreementService.saveUpdate(leaseAgreement);
        return Result.ok();
    }



}
